import os.path
from abc import ABC

from library_test.base_test import BaseLibraryTest


class TestInstallCann(BaseLibraryTest, ABC):
    TESTCASE_DIR = os.path.join(os.path.dirname(__file__), "testcase")

    @classmethod
    def setUpClass(cls) -> None:
        super().setUpClass()
        cls.mock_manager.start_subprocess_patcher(cls.get_module_path(), "sp")

    @classmethod
    def get_module_path(cls):
        return "ascend_deployer.library.install_cann"

    def run_test(self):
        from ascend_deployer.library import install_cann
        install_cann.main()

    @classmethod
    def tearDownClass(cls) -> None:
        super().tearDownClass()
        # 刷新导入，很奇怪，但必须要有，勿删
        from ascend_deployer.library.install_cann import AnsibleModule
